﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.ServiceHosting.ServiceRuntime;

namespace Dtyo_WebRole.Dep
{
    public partial class DepDetails : System.Web.UI.Page
    {
        private DtyoDataSource ds;
        private Department dep;

        protected void Page_Load(object sender, EventArgs e)
        {
            ds = new DtyoDataSource();
            String s = Request.QueryString["rowkey"];
            dep = ds.SelectDepartment(s);

            if (txtName.Text.Length == 0)
            {
                txtName.Text = dep.Name;
            }
            if (txtDescription.Text.Length == 0)
            {
                txtDescription.Text = dep.Description;
            }
        }
        protected void SaveDepartmentButton_Click(object sender, EventArgs e)
        {
            RoleManager.WriteToLog("Information", string.Format("Saving changes to a department"));

            dep.Name = txtName.Text;
            dep.Description = txtDescription.Text;
            ds.SaveDepartment(dep);
            Response.Redirect("DepList.aspx");
        }

        protected void DepDetailsTimer_Tick(object sender, EventArgs e)
        {
            // DepartmentList.DataBind();
        }
    }
}